#pragma once

#include "archive.h"

class UfBuffer 
{
public:
    UfBuffer(const char * buffer, int size);
    UfBuffer(int size, char c = '\0');
    UfBuffer();
    UfBuffer(const UfBuffer& o);
    ~UfBuffer();

    int length() { return len; }
    const char * buffer() { return data; }

    void assign(const char * data, int len);
    void assign(int size, char c = '\0');

    char& at(int offset);
    char& operator[](int offset);
    operator char*() { return data; }
    operator void*() { return data; }
    UfBuffer& operator=(const UfBuffer& o);
    UfBuffer& operator=(const UfBuffer* o);

private:
    int len;
    char* data;
};

Archive& operator<<(Archive& ar, UfBuffer& buf);
Archive& operator>>(Archive& ar, UfBuffer& buf);

std::ostream& operator<<(std::ostream& o, UfBuffer ub);










